<?php
/**
 * 	Bushido
 *
 * @category   Bushido
 * @package    Bushido
 * @copyright  Copyright (c) 2008-2009 Nathan Keyes
 * @author $Author: nkeyes $
 * @version    $Id: UserRole.php 7 2009-11-14 22:42:08Z nkeyes $
 */
 
class Bushido_DbTable_UserRole extends Bushido_Db_Table_Abstract
{
	protected $_name = 'bushido_user_2_bushido_role';
	protected $_sequence = true;
	
	protected $_referenceMap = array
	(
		'User' => array
		(
			'columns' => 'bushido_user_id',
			'refTableClass' => 'Bushido_DbTable_User',
			'refColumns' => 'bushido_user_id'
		),
		'Role' => array
		(
			'columns' => 'bushido_role_id',
			'refTableClass' => 'Bushido_DbTable_Role',
			'refColumns' => 'bushido_role_id'
		)
	);
	
	/**
	 * (non-PHPdoc)
	 * @see library/Bushido/Table/Bushido_Table_Abstract#getSearchableFields()
	 */
	public function getSearchableFields()
	{
	}
	
	/**
	 * (non-PHPdoc)
	 * @see library/Bushido/Db/Table/Bushido_Db_Table_Abstract#_setFieldDetails()
	 */
	protected function _setFieldDetails()
	{
		
	}
	
	/**
	 * (non-PHPdoc)
	 * @see library/Bushido/Table/Bushido_Table_Abstract#getDisplayValue()
	 */
	public static function getDisplayValue(Zend_Db_Table_Row_Abstract $row, $context = null)
	{
		$user = $row->findParentBushido_DbTable_User();
		$role = $row->findParentBushido_DbTable_Role();
		if(!$user || !$role)
		{
			var_dump($row->toArray());
			var_dump($user->toArray());
			var_dump($role->toArray());
			exit;
		}
		return Bushido_Db_Table::getDisplayValue($user) . ' <-> ' . Bushido_Db_Table::getDisplayValue($role);
	}
}